<?php
namespace app\index\controller;

use app\common\controller\Common;
use org\Page;
use think\Exception;
use think\facade\Cache;
use think\facade\Config;
use think\facade\Request;

class Api extends Common
{
    protected function initialize()
    {
        parent::initialize();

    }

    public function home_cid_list($cid = 0)
    {
        $data = curl_server(sprintf("apiv2/classifylist?cid=%s&page=%d&page_size=%d&flag_type=home_cid_list",$cid,1,24));

        $data = $data['data'];
        $data = $this->fetch('home_cid_list',['list' => $data['list']]);
        $this->ajaxJson($data);
    }

    /**
     * 获取章节内容
     * @throws Exception
     */
    public function chapter_content()
    {

        $article_id = $this->request->param("article_id");
        $chapter_id = $this->request->param("chapter_id");
        $flag = base64_decode($this->request->param("flag"));

        if ($article_id != 0 && $chapter_id != 0 && $flag != "") {
            $data = curl_server(sprintf("apiv2/getchaptercontent?article_id=%d&chapter_id=%d&flag=%s",$article_id,$chapter_id,$flag));
            $data = $data['data'];

            $this->ajaxJson($data);
        }else {
            $this->ajaxJson("参数不正确");
        }

    }

}

